package com.jackie.easyble.ui.adapter

import android.bluetooth.BluetoothGattDescriptor
import android.content.Context
import android.view.ViewGroup
import com.chad.library.adapter4.BaseQuickAdapter
import com.chad.library.adapter4.viewholder.DataBindingHolder
import com.jackie.easyble.R
import com.jackie.easyble.databinding.AdapterDeviceDescriptorItemBinding

class DeviceDescriptorRecyclerViewAdapter :
    BaseQuickAdapter<BluetoothGattDescriptor, DeviceDescriptorRecyclerViewAdapter.ViewHolder>() {

    /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
     *
     * 内部类
     *
     * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

    class ViewHolder(parent: ViewGroup) :
        DataBindingHolder<AdapterDeviceDescriptorItemBinding>(
            R.layout.adapter_device_descriptor_item,
            parent
        )

    /**
     * Implement this method and use the helper to adapt the view to the given item.
     *
     * 实现此方法，并使用 [holder] 完成 item 视图的操作
     *
     * @param holder A fully initialized helper.
     * @param item   The item that needs to be displayed.
     */
    override fun onBindViewHolder(
        holder: ViewHolder,
        position: Int,
        item: BluetoothGattDescriptor?
    ) {
        holder.binding.item = item
    }


    override fun onCreateViewHolder(
        context: Context,
        parent: ViewGroup,
        viewType: Int
    ): ViewHolder {
        return ViewHolder(parent)
    }
}